package TSV_1990;

import com.google.common.util.concurrent.CycleDetectingLockFactory;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.internal.WebElementToJsonConverter;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;


/**
 * Created with IntelliJ IDEA.
 * User: Vitalik
 * Date: 10.11.13
 * Time: 0:37
 * To change this template use File | Settings | File Templates.
 */
public class tsv_test {
   // @BeforeTest

  // Webt waitts = new WebDriverWait(driver,10);

    public WebDriver driver;
    public WebElement query;


    @Test
    public void test()
    {
        driver = new FirefoxDriver();
        driver.get("http://vmdaily.ru/");
        WebDriverWait wait = new WebDriverWait(driver, 20) ;
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/div/header/div[2]/div[1]/div/ul/li[2]/h3/a")));
            query = driver.findElement(By.xpath("/html/body/div/header/div[2]/div[1]/div/ul/li[2]/h3/a"));
            query.click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/div/section/section/article/div[9]/div[1]/button")));
            query = driver.findElement(By.xpath("/html/body/div/section/section/article/div[9]/div[1]/button"));
            query.click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.className("editor")));
            query = driver.findElement(By.className("editor"));
            query.sendKeys("Самый дебильный сайт в мире!");
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/div/section/section/article/div[9]/div[2]/form/div[4]/input[4]")));
            query.findElement(By.xpath("/html/body/div/section/section/article/div[9]/div[2]/form/div[4]/input[4]")).click();
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"user-info\"]/form/div[1]/div[2]/div[1]/input[1]")));
            query.findElement(By.xpath("//*[@id=\"user-info\"]/form/div[1]/div[2]/div[1]/input[1]")).sendKeys("tsibaev");
        wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"user-info\"]/form/div[1]/div[2]/div[2]/input")));
            query.findElement(By.name("//*[@id=\"user-info\"]/form/div[1]/div[2]/div[2]/input")).sendKeys("qwerty");

      //Проблемы с поиском поля для ввода пароль.Возможно что-то не то с Xpath.
    }
}

